﻿#region License

// Copyright (c) 2012, Zhiyong Yang.
// All rights reserved.
// 
// 
// This software is licensed under the GNU General Public License version 2 (GPLv2).
// 
// Contact Me: 
//  Mail: younthu@yahoo.com.cn
//  MSN:  evil_eve_live@hotmail.com

#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using BubbelsModel;

namespace BlubbelsModelTest
{
    [TestFixture]
    public class BubbelsTableTest
    {
        [Test]
        public void GetUnionTest()
        {
            BubbelsTable model = new BubbelsTable(100, 100);

            // Random test with empty model
            Random rand = new Random(DateTime.Now.Second);
            for (int i = 0; i < 100; i++)
            {
                int row = rand.Next() % 120;
                int col = rand.Next() % 120;

                Assert.IsTrue(model.GetUnion(col, row).Count == 0);
            }


            // 
            int[] data = new int[100];
            for (int i = 0; i < 100; i++)
            {
                data[i] = 1;
            }

            model.FillRow(data, 99, 100);
            model.FillCell(0,98,2);

            for (int i = 0; i < 100; i++)
            {
                Assert.AreEqual(100, model.GetUnion(i, 99).Count);
            }

            // Point(0,98) should be ball,no conjunctional ball
            Assert.AreEqual(1, model.GetUnion(0, 98).Count);


            // Others are empty
            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 98; j++)
                {
                    Assert.AreEqual(0,model.GetUnion(i,j).Count);
                }
            }

        }
    }
}
